package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.annotation.RequiresPermissionsDesc;
import com.qf.pojo.DtsFeedback;
import com.qf.service.DtsFeedbackService;
import com.qf.util.ResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0
 * @auther Administrator
 * @date 2023/2/24 15:47
 */
@RequestMapping("/admin/feedback")
@RestController
@CrossOrigin
public class FeedbackController {
    @Autowired
    private DtsFeedbackService dtsFeedbackService;

    @RequiresPermissions(value = {"admin:feedback:list"})
    @RequiresPermissionsDesc(menu = {"用户管理","意见反馈"}, button = "查询")
    @GetMapping("/list")
    public Object list(
            Integer userId,
            String username,
            String sort,
            String order,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "20") Integer limit
    ){
        IPage<DtsFeedback> ipage = dtsFeedbackService.findRolePageByQuery(userId, username,sort,order,page,limit);
        Map data = new HashMap<>();
        data.put("total",ipage.getTotal());
        data.put("items",ipage.getRecords());
        return ResponseUtil.ok(data);
    }

}
